package 分类.双指针;

public class 移除元素 {
    public static int removeElement(int[] nums, int val) {
        int slow=0,fast=0;
        while (fast<nums.length){
            if(nums[fast]==val){
                fast++;
            }else {
                nums[slow]=nums[fast];
                slow++;
                fast++;
            }
        }
        return slow;
    }

    public static void main(String[] args) {
        int[] nums={1,2,3,3,3,3,4,5};
        System.out.println(removeElement(nums,3));
    }
}
